﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Shove.Web.UI;

public partial class UserControls_AllGoodType_New : UCBase
{
    public UserControls_AllGoodType_New()
    {
        Name = "商品分类列表_2";

        swpas = new ShoveWebPartAttribute[1];

        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "1,1000", 180, "控件宽度");
        //swpas[1] = new ShoveWebPartAttribute_Int("导航高度", "1,300", 28, "导航高度");
        //swpas[2] = new ShoveWebPartAttribute_Int("导航背景图片单元格宽度", "1,600", 106, "导航背景图片单元格宽度");

        //swpas[3] = new ShoveWebPartAttribute_Text("导航字体CSS样式", "", "title14_bai", "导航字体CSS样式");

        //swpas[4] = new ShoveWebPartAttribute_Image("导航背景图片1", "", "images/title_bg_1.jpg", "导航背景图片1");
        //swpas[5] = new ShoveWebPartAttribute_Image("导航背景图片2", "", "images/title_bg_hui.jpg", "导航背景图片2");
        //swpas[6] = new ShoveWebPartAttribute_Image("每行类别个数", "1,10", 4, "每行类别个数");
        //swpas[7] = new ShoveWebPartAttribute_Image("大类背景图片", "", "images/category_bg_1.jpg", "大类背景图片");
        //swpas[8] = new ShoveWebPartAttribute_Int("大类别个数", "1,20", 8, "大类别个数");
        //swpas[9] = new ShoveWebPartAttribute_Int("小类别个数", "1,30", 5, "小类别个数");
        //swpas[10] = new ShoveWebPartAttribute_Int("大类别行高", "1,300", 25, "大类别行高");
        //swpas[11] = new ShoveWebPartAttribute_Int("小类别行高", "1,300", 22, "小类别行高");
        //swpas[12] = new ShoveWebPartAttribute_Text("大类别名样式", "", "td14", "大类别名样式");
        //swpas[13] = new ShoveWebPartAttribute_Text("小类别名样式", "", "blue12", "小类别名样式");

        //swpas[14] = new ShoveWebPartAttribute_Color("控件边框颜色", "#E7C890", "控件边框颜色");

        //swpas[15] = new ShoveWebPartAttribute_Int("大类单元格宽度", "1,600", 150, "大类单元格宽度");
        //swpas[16] = new ShoveWebPartAttribute_Int("小类别名称宽度", "1,500", 132, "小类别名称宽度");
        //swpas[17] = new ShoveWebPartAttribute_Image("小类别名称背景图片", "", "images/category_bg_2.jpg", "小类别名称背景图片");
        //swpas[18] = new ShoveWebPartAttribute_Image("小类别前图标", "", "images/point_bg.jpg", "小类别前图标");
        //swpas[19] = new ShoveWebPartAttribute_Image("小图标背景图片", "", "images/category_bg_2.jpg", "小图标背景图片");
    }

    private void InitlayOut()
    {
        tabctr.Width = swpAttributes[0];
        //tabctr.BgColor = swpAttributes[14];

        //tdsign.Height = swpAttributes[1];
        //tdsign.Width = swpAttributes[2];
        //tdsign.Attributes.Add("class", swpAttributes[3]);
        //tdsign.Style.Add("background-image", "url('" + swpAttributes[4] + "')");
        //tdspace.Style.Add("background-image", "url('" + swpAttributes[5] + "')");
        //tdspace.Width = (Shove._Convert.StrToInt(swpAttributes[0], 220) - Shove._Convert.StrToInt(swpAttributes[2], 106)).ToString();

        //sdlOneGoodType.ItemStyle.CssClass = swpAttributes[12];
        //sdlOneGoodType.ItemStyle.Height = new Unit(swpAttributes[10]);
        //sdlOneGoodType.RepeatColumns = Shove._Convert.StrToInt(swpAttributes[6], 4);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        InitlayOut();
        BindData();
    }

    protected void BindData()
    {
        DataTable dt = null;

        dt = new DAL.Tables.tbl_Shop_GoodType().Open("", " ParentID='00' and TypeStatus = 1", "");

        rpProType.DataSource = dt;
        rpProType.DataBind();
    }

    protected void rpProType_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        HtmlInputHidden id = (HtmlInputHidden)e.Item.FindControl("id");
        Label lab = (Label)e.Item.FindControl("labProList");
        string TypeID = id.Value;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (TypeID != "" && TypeID != "00")
        {
            sb.Append("<ul>");
            DataTable dt = null;

            dt = new DAL.Tables.tbl_Shop_GoodType().Open("", "ParentID = '" + TypeID + "' and TypeStatus = 1", "");
            for (int j = 0; j < dt.Rows.Count; j++)
            {
                sb.Append("<li class=\"extMenu\">");
                sb.Append("<a href='Default.aspx?PN=goods_search_list&Page=Type&GoodType=" + dt.Rows[j]["ID"].ToString() + "' title=\"" + dt.Rows[j]["TypeName"].ToString() + "\">" + dt.Rows[j]["TypeName"].ToString() + "</a>");
                sb.Append("<span>-</span>");

                //加载它的三级菜单
                string TypeID2 = dt.Rows[j]["ID"].ToString();
                DataTable dt2 = new DAL.Tables.tbl_Shop_GoodType().Open("top 10 * ", "ParentID = '" + TypeID2 + "' and TypeStatus = 1", "");

                if (dt2 != null && dt2.Rows.Count > 0)
                {
                    sb.Append("<del>");
                    sb.Append("<a href='Default.aspx?PN=goods_search_list&Page=Type&GoodType=" + dt2.Rows[0]["ID"].ToString() + "' title=\"" + dt2.Rows[0]["TypeName"].ToString() + "\">" + dt2.Rows[0]["TypeName"].ToString() + "</a>");
                    sb.Append("</del>");
                    sb.Append("<blockquote><dl> <dd>");

                    for (int a = 0; a < dt2.Rows.Count; a++)
                    {
                        sb.Append("<a href='Default.aspx?PN=goods_search_list&Page=Type&GoodType=" + dt2.Rows[a]["ID"].ToString() + "' title=\"" + dt2.Rows[a]["TypeName"].ToString() + "\">" + dt2.Rows[a]["TypeName"].ToString() + "</a>");
                        if (a > 8)
                        {
                            sb.Append("<a href='Default.aspx?PN=goods_search_list&Page=Type&GoodType=" + dt.Rows[j]["ID"].ToString() + "' title=\"更多商品...\">更多商品...</a>");
                        }

                    }
             

                    sb.Append(" </dd></dl></blockquote>");
                }
                sb.Append("</li>");
            }

            sb.Append("<ul>");
        }

        lab.Text = sb.ToString();
    }

}
